home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / internet / amitcp3.0b / src.lha / src / amitcp / api / allocdatabuffer.c next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  1.3 KB  |  57 lines

  1. RCS_ID_C="$Id: allocdatabuffer.c,v 1.4 1994/02/16 06:31:55 jraja Exp $";
  2. /*
  3.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  4.  *                    Helsinki University of Technology, Finland.
  5.  *                    All rights reserved.
  6.  *
  7.  * Created: Sun Jun 13 01:09:17 1993 too
  8.  * Last modified: Wed Feb 16 08:31:10 1994 jraja
  9.  *
  10.  * HISTORY
  11.  * $Log: allocdatabuffer.c,v $
  12.  * Revision 1.4  1994/02/16  06:31:55  jraja
  13.  * Eliminated unnecessary checks :-) (see api/allocdatabuffer.h).
  14.  *
  15.  * Revision 1.3  1994/02/14  00:42:52  ppessi
  16.  * Eliminated unnecessary allocations.
  17.  *
  18.  * Revision 1.2  1994/01/20  02:18:00  jraja
  19.  * Added #include <conf.h> as the first include.
  20.  *
  21.  * Revision 1.1  1993/06/12  22:57:18  too
  22.  * Initial revision
  23.  *
  24.  *
  25.  */
  26.  
  27. #include <conf.h>
  28.  
  29. #include <exec/types.h>
  30.  
  31. #include <sys/malloc.h>
  32.  
  33. #include <api/amiga_api.h>
  34. #include <api/allocdatabuffer.h>
  35.  
  36. BOOL doAllocDataBuffer(struct DataBuffer * DB, int size)
  37. {
  38.   if (DB->db_Addr)
  39.     bsd_free(DB->db_Addr, M_TEMP);
  40.   
  41.   if ((DB->db_Addr = bsd_malloc(size, M_TEMP, M_WAITOK)) == NULL) {
  42.     DB->db_Size = 0;
  43.     return FALSE;
  44.   }
  45.   DB->db_Size = size;
  46.   return TRUE;
  47. }
  48.  
  49. VOID freeDataBuffer(struct DataBuffer * DB)
  50. {
  51.   if (DB->db_Addr)
  52.     bsd_free(DB->db_Addr, M_TEMP);
  53.   DB->db_Size = 0;
  54.   DB->db_Addr = NULL;
  55. }
  56.  
  57.